<?php

namespace common\models\shop;

use Yii;

/**
 * This is the model class for table "shop_slide".
 *
 * @property string $id
 * @property string $title
 * @property string $picture
 * @property integer $status
 * @property string $link
 */
class ShopSlide extends \yii\db\ActiveRecord
{

    //主要用于日志记录
    public $uselog = [
        'tabcomment' => '幻灯片',      //用于修改了什么的显示
        'mainfield' => 'title',      //主要的显示标题的字段
        'picturefield' => [],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];


    const ACTIVE_STATUS = 1;
    const HIEEDN_STATUS = 0;
    public static $statues = [
        self::ACTIVE_STATUS => '显示',
        self::HIEEDN_STATUS => '不显示',
    ];




    const TYPE_SHOP = 1;
    const TYPE_RASING = 2;
    const TYPE_FARMERHOUSE = 3;
    const TYPE_ARTICLE = 4;

    public static $types = [
        self::TYPE_SHOP => '商城',
        self::TYPE_RASING => '认养',
        self::TYPE_FARMERHOUSE => '农家乐',
        self::TYPE_ARTICLE => '文章',
    ];



    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shop_slide';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title', 'status', 'link'], 'required'],
            [['status','type'], 'integer'],
            [['title'], 'string', 'max' => 100],
            [['link'], 'string', 'max' => 255],
            [['picture'], 'image', 'extensions' => 'jpg, jpeg, gif, png', 'on' => ['insert', 'update']],


        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '标题',
            'picture' => '缩略图',
            'status' => '状态',
            'link' => '连接',
            'type' => '用于'
        ];
    }
}
